#include<iostream>
using std::cin;
using std::cout;
using std::endl;
int main(){
    int year,month,day;
    char a,b;
    cin>>year>>a>>month>>b>>day;
    if(month>=13||day>=32){
        cout<<"NO"<<endl;
    }
    else{
        if(year%100!=0&&year%4==0||year%400==0&&year%100==0){
            if(month==4||month==6||month==9||month==11){
                if(day>=31){
                    cout<<"NO"<<endl;
                }
                else cout<<"YES"<<endl;
            }
            else if(month==2){
                if(day>=30){
                    cout<<"NO"<<endl;
                }
                else cout<<"YES"<<endl;
            }
            else cout<<"YES"<<endl;
        }
        else {
            if(month==4||month==6||month==9||month==11){
                if(day>=31){
                    cout<<"NO"<<endl;
                }
                else cout<<"YES"<<endl;
            }
            else if(month==2){
                if(day>=29){
                    cout<<"NO"<<endl;
                }
                else cout<<"YES"<<endl;
            }
            else cout<<"YES"<<endl;
        }
        }
return 0;
}
